<?php
/**
 * Created by PhpStorm.
 * User: wjj
 * Date: 2016/11/1
 */

namespace app\logic;

use app\models\Article;

class ArticleLogic
{
    public function getList($article_type,$extend_type=0){
        $article = Article::find()->where(['article_type'=>$article_type]);
        if($article_type==3){
            $article->andWhere(['extend_type'=>$extend_type]);
        }
        $article->andWhere(['is_del'=>0])->orderBy('article_id DESC');
        return $article->asArray()->all();
    }

    public function getDetail($article_id){
        $article = Article::findOne(['article_id'=>$article_id]);
        $article->read_num += 1;
        $article->save();
        return $article->toArray();
    }



}
